#ifndef _ABSTRACTFACTORY_H_
#define _ABSTRACTFACTORY_H_

#include "Product.h"
#include <iostream>

class AbstractApple;
class AbstractBanana;
class AbstractPear;

class ChinaApple;
class ChinaBanana;
class ChinaPear;

class AmericaApple;
class AmericaBanana;
class AmericaPear;

class JapanApple;
class JapanBanana;
class JapanPear;

class AbstractFactory
{
public:
    virtual AbstractApple* CreateApple() = 0;
    virtual AbstractBanana* CreateBanana() = 0;
    virtual AbstractPear* CreatePear() = 0;
};

class ChinaFactory : public AbstractFactory
{
public:
    virtual AbstractApple* CreateApple()
    {
        return new ChinaApple();
    }
    virtual AbstractBanana* CreateBanana()
    {
        return new ChinaBanana();
    }
    virtual AbstractPear* CreatePear()
    {
        return new ChinaPear();
    }
};

class AmericaFactory : public AbstractFactory
{
public:
    virtual AbstractApple* CreateApple()
    {
        return new AmericaApple();
    }
    virtual AbstractBanana* CreateBanana()
    {
        return new AmericaBanana();
    }
    virtual AbstractPear* CreatePear()
    {
        return new AmericaPear();
    }
};

class JapanFactory : public AbstractFactory
{
public:
    virtual AbstractApple* CreateApple()
    {
        return new JapanApple();
    }
    virtual AbstractBanana* CreateBanana()
    {
        return new JapanBanana();
    }
    virtual AbstractPear* CreatePear()
    {
        return new JapanPear();
    }
};

#endif // _ABSTRACT_FACTORY_H_